<?php 

				$endl = 1;
		        $id = 0;

	            foreach($adData as $row) {
	                   if($endl%3==0)
	                   echo "<div class='row'>"; 

	            ?>

	                <div class="col-md-3 col-sm-4 portfolio-item">
	                    <a href="#portfolioModal<?php echo $id; ?>" class="portfolio-link" data-toggle="modal">
	                        <div class="portfolio-hover">
	                            <div class="portfolio-hover-content">
	                                <i class="fa fa-plus fa-3x"></i>
	                            </div>
	                        </div>
	                        <div style="height:170px; overflow:hidden; border: 1px solid; border-color:#e0e0e0; background:#e0e0e0;">
	                            <center>
	                                <img src='<?php echo $row->img_1; ?>' class="img-responsive" alt="">
	                            </center>
	                        </div>
	                    </a>
	                    <div class="portfolio-caption">
	                        <h4><?php echo $row->ad_title; ?></h4>
	                        <p class="text-muted"><?php echo $row->price; ?> pkr</p>
	                    </div>
	                </div>


	            <?php
	            if($endl % 3 ==0)
	                echo "</div>";

	            $endl++;
	            $id++; 

	             }
	              

	              ?> 

	    </div>
	</section>


	<!-- modals -->
	<?php 
	$i=0;
	foreach($adData as $row) { ?>

	    <div class="portfolio-modal modal fade" id="portfolioModal<?php echo $i; ?>" tabindex="-1" role="dialog" aria-hidden="true">
	        <div class="modal-content">
	            <div class="close-modal" data-dismiss="modal">
	                <div class="lr">
	                    <div class="rl">
	                    </div>
	                </div>
	            </div>
	            <div class="container">
	                <div class="row">
	                    <div class="col-lg-8 col-lg-offset-2">
	                        <div class="modal-body">
	                            <!-- Project Details Go Here -->
	                            <h2><?php echo $row->ad_title; ?></h2>
	                                <p class="item-intro text-muted"><b>Posted By</b></p>
	                            
	                                <center>
	                                    <div class="img-div-xsml"  >
	                                        <img src='<?php echo $row->dp; ?>' />
	                                    </div> 
	                                </center>
	                                
	                                <center>
	                                    <p class="item-intro"><a  href="<?= base_url() ?>Site/view_profile/<?= $row->user_id ?>"><?php echo $row->full_name; ?></a></p>
	                                </center>
	                                                            
	                            <br>

	                            <div class="row">
	                                <div class="col-md-12">
	                                    <center>
	                                     <img class="img-responsive"  src='<?php echo $row->img_1; ?>' alt="">
	                                     </center>
	                                </div>
	                            </div>
	                            <div class="row">
	                                <div class="col-md-6">
	                                    <center>
	                                    <img class="img-responsive"  src='<?php echo $row->img_2; ?>' alt="">
	                                    </center>
	                                </div>
	                                <div class="col-md-6">
	                                    <center>
	                                    <img class="img-responsive" src='<?php echo $row->img_3; ?>' alt="">
	                                    </center>
	                                </div>
	                            </div>
	      
	                            
	                            <h3>Discription:</h3>
	                            <p><?php echo $row->disc; ?></p>
	                            
	                            <p><strong>Contact #:</strong><?php echo $row->contact; ?></p>
	                            <button class="btn btn-primary">Send E-mail</button>
	                            <br><br>
	                            
	                            <ul class="list-inline">
	                                <li><p><b>Date:</b> <?php echo $row->timestamp; ?></p></li>
	                                <li><p><b>Price: </b><?php echo $row->price; ?>Rs</p></li>
	                                <li><p><b>Category: </b><?=$row->cat_name ?></p></li>
	                                <li><p><b>Views: </b><?=$row->views ?></p></li>
	                            </ul>
	                            <ul class="list-inline">
	                                <li><p><b>Keywords:</b><?= $row->keywords ?></p></li>
	                                
	                            </ul>
	                            
	                            <button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i>Close</button>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div>
    </div>

    <?php 
    $i++;
} ?>